home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 71 / MOBICLIC 71.ISO / mac / DATA / COMMUN / temp0001 / 00009_Script_moteurs < prev    next >
Text File  |  2004-12-05  |  17KB  |  574 lines

  1. -- affiche un Θlastique entre un objet origine et un objet cible
  2.  
  3. global traitLiaison, volumeOn, menuOuvert
  4.  
  5. on initTraitLiaison sPoint,remplacement
  6.   -- initialisation d'une procΘdure traitLaison
  7.   -- sPoint est le numΘro de la piste portant le point mobile (ex: acteur TrL Point de menu.cst)
  8.   -- remplacement : si 0 l'acteur de la piste sPoint est utilisΘ, 1 il est remplacΘ par l'acteur
  9.   -- de la piste s
  10.   global traitLiaison
  11.   cursor 290
  12.   set s = the currentSpriteNum
  13.   set x = the mouseH
  14.   set y = the mouseV
  15.   if the paramCount =1 then
  16.     set remplacement=0
  17.   end if
  18.   jingle( 3, "poc", "OUT")
  19.   set the rect of sprite (sPoint -1) to rect(x,y,x,y)
  20.   set the locH of sprite sPoint = x
  21.   set the locV of sprite sPoint = y
  22.   if remplacement = 1 then
  23.     sprite(sPoint).member = sprite(s).member
  24.   end if
  25.   afficherPistes (sPoint -1),sPoint
  26.   set traitLiaison = [s,x,y]
  27.   updateStage
  28. end
  29.  
  30. on traitLiaison p1,p2,p3
  31.   -- p1 : piste du trait pente 1 (ex : acteur Trl 1 de la distribution menus.cst)
  32.   -- p2 : piste du trait pente -1  (ex : acteur TrL -1 de la distribution menus.cst)
  33.   -- p3 : piste du point mobile (ex : acteur TrL Point de la distribution menus.cst)
  34.   -- la variable liste traitLiaison contient :
  35.   ---- 1 : piste de l'objet origine
  36.   ---- 2 : locH de l'objet origine
  37.   ---- 3 : locV de l'objet origine
  38.   
  39.   set the locH of sprite p3 = the mouseH
  40.   set the locV of sprite p3 = the mouseV
  41.   set H = the locH of sprite p3
  42.   set V = the locV of sprite p3
  43.   
  44.   if V < getAt(traitLiaison,3) then
  45.     -- le point de choix est plus haut que l'objet de dΘpart
  46.     set y1 = V
  47.     set y2 = getAt(traitLiaison,3)
  48.     if abs(y1-y2)<4 then set y2 = y1 + 4
  49.     
  50.     if H > getAt(traitLiaison,2) then
  51.       -- le point de choix est α droite de l'objet de dΘpart
  52.       set h1 = getAt(traitLiaison,2)
  53.       set h2 = h
  54.       if abs(h1-h2)<4 then set h2 = h1 + 4
  55.       afficherPistes p1
  56.       masquerPistes p2
  57.       set the rect of sprite p1 to rect(h1,y1,h2,y2)
  58.     else
  59.       -- le point de choix est α gauche de l'objet de dΘpart
  60.       set h1 = h
  61.       set h2 = getAt(traitLiaison,2)
  62.       if abs(h1-h2)<4 then set h2 = h1 + 4
  63.       afficherPistes p2
  64.       masquerPistes p1
  65.       set the rect of sprite p2 to rect(h1,y1,h2,y2)
  66.     end if
  67.   else
  68.     -- le point de choix est plus bas que l'objet de dΘpart
  69.     set y1 = getAt(traitLiaison,3)
  70.     set y2 =  V
  71.     if abs(y1-y2)<4 then set y2 = y1 + 4
  72.     if H > getAt(traitLiaison,2) then
  73.       -- le point de choix est α droite de l'objet de dΘpart
  74.       set h1 = getAt(traitLiaison,2)
  75.       set h2 = h
  76.       if abs(h1-h2)<4 then set h2 = h1 + 4
  77.       afficherPistes p2
  78.       masquerPistes p1
  79.       set the rect of sprite p2 to rect(h1,y1,h2,y2)
  80.     else
  81.       -- le point de choix est α gauche de l'objet de dΘpart
  82.       set h1 = h
  83.       set h2 = getAt(traitLiaison,2)
  84.       if abs(h1-h2)<4 then set h2 = h1 + 4
  85.       afficherPistes p1
  86.       masquerPistes p2
  87.       set the rect of sprite p1 to rect(h1,y1,h2,y2)
  88.     end if
  89.   end if
  90.   updateStage
  91. end
  92.  
  93. on glisserDeposer s1,s2,s3,s4,mode
  94.   -- s1 : est la piste cible de plus bas numΘro
  95.   -- s2 : est la piste cible de numΘro le plus ΘlevΘ
  96.   -- s3 : piste acteur α dΘplacer de plus bas numΘro
  97.   -- s4 : piste point en bout d'Θlastique
  98.   -- mode : l'objet dΘplacΘ est supprimΘ si valeur 1, laissΘ en place si 0
  99.   if the paramCount =3 then
  100.     set mode = 0
  101.   end if
  102.   global traitLiaison, choix
  103.   if the visible of sprite s4 = 1 then
  104.     cursor -1
  105.     set s = getAt(traitLiaison,1)
  106.     repeat with i = s1 to s2
  107.       if sprite s4 intersects i then
  108.         -- emplacement occupΘ ? ------------------------------------
  109.         if getAt(choix,i+1-s1)<>0 then
  110.           if mode = 1 then
  111.             afficherPistes s3-1+getAt(choix,i-s1+1)
  112.           end if
  113.         end if
  114.         -- mise en place de l'ΘlΘment glissΘ -----------------------
  115.         set the memberNum of sprite i = the memberNum of sprite s4
  116.         updateStage
  117.         setAt choix,i-s1+1,s-s3+1
  118.         afficherPistes i
  119.         if mode = 1 then
  120.           masquerPistes s
  121.         end if
  122.         updateStage
  123.         puppetSound 2, "poc"
  124.         exit repeat
  125.       end if
  126.     end repeat
  127.     masquerPistes s4-2,s4-1,s4
  128.     -- l'ΘlΘment dΘposΘ n'est en intersection avec aucune zone
  129.     if i=1+s2 then
  130.       
  131.       jingle( 2, "echec_01", "OUT")
  132.     end if
  133.   end if
  134. end
  135.  
  136. on controlePanier
  137.   -- ce script est α recopier et placer dans un bouton au mouseUp
  138.   -- les valeurs utilisΘes sont indicatives
  139.   global choix
  140.   set L =[[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]]
  141.   -- s1 = numΘro de la piste cible de plus bas numΘro 
  142.   set s1 = 20
  143.   -- s2 = numΘro de la piste acteur α glisser la plus basse
  144.   set s2 = 40
  145.   set test = 0
  146.   -- test du premier panier --------------------------
  147.   set L1 = getAt(L,1)
  148.   repeat with i=1 to 3
  149.     if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
  150.       set test = 1
  151.       afficherPistes s2-1+getAt(choix,i)
  152.       masquerPistes s1-1+i
  153.       setAt choix,i,0
  154.     end if
  155.   end repeat
  156.   -- test du deuxiΦme panier --------------------------
  157.   set L1 = getAt(L,2)
  158.   repeat with i=4 to 6
  159.     if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
  160.       set test = 1
  161.       afficherPistes s2-1+getAt(choix,i)
  162.       masquerPistes s1-1+i
  163.       setAt choix,i,0
  164.     end if
  165.   end repeat
  166.   -- test du troisiΦme panier --------------------------
  167.   set L1 = getAt(L,3)
  168.   repeat with i=7 to 9
  169.     if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
  170.       set test = 1
  171.       afficherPistes s2-1+getAt(choix,i)
  172.       masquerPistes s1-1+i
  173.       setAt choix,i,0
  174.     end if
  175.   end repeat
  176.   -- test du quatriΦme panier ---------------------------
  177.   set L1 = getAt(L,4)
  178.   repeat with i=10 to 12
  179.     if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
  180.       set test = 1
  181.       afficherPistes s2-1+getAt(choix,i)
  182.       masquerPistes s1-1+i
  183.       setAt choix,i,0
  184.     end if
  185.   end repeat
  186.   -- test du cinquiΦme panier -----------------------------
  187.   set L1 = getAt(L,5)
  188.   repeat with i=13 to 15
  189.     if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
  190.       set test = 1
  191.       afficherPistes s2-1+getAt(choix,i)
  192.       masquerPistes s1-1+i
  193.       setAt choix,i,0
  194.     end if
  195.   end repeat
  196.   -- controle final -----------------------------------------
  197.   if test=0 then
  198.     -- son de rΘussite α placer ici
  199.     go to "fin"
  200.   else
  201.     jingle( 2, "echec_01","OUT")
  202.   end if
  203. end
  204. -------------------------------------------------------------
  205. -- test clic sur Θcran
  206. on testClic
  207.   global gJLM_W
  208.   if the pauseState = 0 and gJLM_W = 0 then
  209.     return 1
  210.   else
  211.     return 0
  212.   end if
  213. -------------------------------------------------------------------------
  214. -- repΘrage de coordonnΘes d'acteurs sur la scΦne
  215. on posXY a,b
  216.   -- un champ nommΘ "locHV" doit exister dans la distribution interne
  217.   repeat with i= a to b
  218.     put the locH of sprite i into word 1 of line(i-a+1) of field "locHV"
  219.     put the locV of sprite i into word 2 of line(i-a+1) of field "locHV"
  220.   end repeat
  221. end
  222. ------------------------------------------------------
  223. on imprime
  224.   -- impression de l'Θcran
  225.   prevue = the optionDown
  226.   doc = xtra("PrintOMatic").new()
  227.   --  if not objectP(doc) then exit
  228.   --  setPrintableMargins doc
  229.   pipeline = xtra("FILEXtra4").new()
  230.   target = pipeline.fx_FolderGetSpecialPath("kDesktopFolderType")
  231.   member("TAMPON_ECRAN").picture = the stage.picture
  232. --  exportPicture("TAMPON_ECRAN",target&"MOBIPRINT_TEMP.jpg")
  233. --  open "@//WIN98PRINTER/WIN98PRINTER"
  234.   
  235.     if doPageSetUp (doc) = true then
  236.       newPage doc
  237.       H = getPageWidth(doc)
  238.       V = getPageHeight(doc)
  239.       X =(H-640)/2
  240.       Y =(V-480)/2
  241.       if H>=640 then
  242.         drawStagePicture doc, Point(X,Y),Rect(1,1,640,480),true
  243.       else
  244.         drawStagePicture doc, rect(1,1,H,V),Rect(1,1,640,480),true
  245.       end if
  246.       if doJobSetup (doc) = TRUE then
  247.         if prevue = 1 then
  248.           printPreview doc
  249.         else
  250.           setProgressMsg doc , "Impression d'un Θcran Mobiclic en cours... "
  251.           print doc
  252.         end if
  253.       end if
  254.     end if
  255.     doc = 0
  256. end imprime
  257. --------------------------------------------------------------------
  258. -- impression d'un acteur
  259. on imprimeActeur n,c
  260.   if the paramCount=1 then
  261.     set c=1
  262.   end if
  263.   set prevue = the optionDown
  264.   if prevue=1 then
  265.     printPreview member n of castLib c
  266.   else
  267.     print member n of castLib c
  268.   end if
  269. end imprimeActeur
  270.  
  271. -- impression d'une planche de cartes
  272. -- la zone placΘe sous le rectangle de la piste s est imprimΘe en optimisant
  273. -- le remplissage de la feuille (portrait ou paysage)
  274. on imprimeCartes s
  275.   updateStage
  276.   set prevue = the optionDown
  277.   -- gΘnΘrer le fichier impression si validation du format d'impression
  278.   doc = xtra("PrintOMatic").new()
  279.   if not objectP(doc) then exit
  280.   setPrintableMargins doc
  281.   if doPageSetUp (doc) = true then
  282.     newPage doc
  283.     H = getPageWidth(doc)
  284.     V = getPageHeight(doc)
  285.     H2 = 10+sprite(s).width
  286.     V2 = 10+sprite(s).height
  287.     nx = H/H2
  288.     ny = V/V2
  289.     r = sprite(s).rect
  290.     repeat with y = 1 to ny
  291.       repeat with x = 1 to nx
  292.         drawStagePicture doc, Point(1+(x-1)*H2,1+(y-1)*V2),r,true
  293.       end repeat
  294.     end repeat
  295.     if prevue=1 then
  296.       if doJobSetup (doc) = TRUE then
  297.         printPreview doc
  298.       end if
  299.     else
  300.       if doJobSetup (doc) = TRUE then
  301.         setProgressMsg doc , "Impression en cours... "
  302.         print doc
  303.       end if
  304.     end if
  305.   end if
  306.   doc = 0
  307. end
  308.  
  309. -- temporisation (en secondes)
  310. on temporise t
  311.   t= t*60.0
  312.   d = the timer
  313.   repeat while the timer - d < t
  314.   end repeat
  315. end temporise
  316.  
  317. -- conversion d'un chemin d'accΦs de Mac α Dos
  318. on nomDos nom
  319.   if the machineType = 256 then
  320.     repeat with i=1 to the number of chars of nom
  321.       if char i of nom = ":" then
  322.         put "\" into char i of nom
  323.       end if
  324.     end repeat
  325.   end if
  326.   return nom
  327. end nomDos
  328.  
  329. -- affichage successif des pistes d'un groupe de pistes
  330.  
  331. on choixElements a,b,mode,s
  332.   -- gΦre l'affichage alternatif d'une piste parmi un groupe
  333.   -- de pistes dont les numΘros sont compris entre a et b
  334.   -- mode : 0 passage par un Θtat vide, 1 pas d'Θtat vide
  335.   -- son : 0 pas de son poc, 1 son activΘ (1 par dΘfaut)
  336.   case the paramCount of
  337.     2:set mode=0
  338.       set s=1
  339.     3:set s=1
  340.   end case
  341.   
  342.   repeat with i=a to b
  343.     if the visible of sprite i=1 then
  344.       exit repeat
  345.     end if
  346.   end repeat
  347.   if i=b+1 then
  348.     -- aucune piste n'est affichΘe
  349.     set piste=a
  350.   else
  351.     if i=b then
  352.       -- derniΦre piste affichΘe : selon mode
  353.       if mode=0 then
  354.         set piste=value(field "PPGS")
  355.       else
  356.         set piste=a
  357.       end if
  358.     else
  359.       -- cas gΘnΘral : afficher la piste suivante
  360.       set piste=i+1
  361.     end if
  362.   end if
  363.   -- dissimulation de toutes les pistes
  364.   repeat with i=a to b
  365.     masquerPistes i
  366.   end repeat
  367.   -- affichage de la bonne piste
  368.   if piste<>value(field "PPGS") then
  369.     afficherPistes piste
  370.   end if
  371.   if s=1 then
  372.     sound(2).play(member "poc")
  373.   end if
  374. end
  375.  
  376. -- tirage d'une liste alΘatoire
  377. on randomList nbreElts, nbreMaxi
  378.   -- tirage alΘatoire d'une liste de nombres dont le nombre d'ΘlΘments est nbreElts
  379.   -- et dont chaque valeur est comprise entre 1 et nbreMaxi
  380.   ---- nbreElts = le nombre d'ΘlΘments de la liste
  381.   ---- nbreMaxi = nombre maximum pouvant Ωtre incorporΘ α la liste
  382.   randomList=[]
  383.   if the paramCount=1 then
  384.     nbreMaxi=nbreElts
  385.   end if
  386.   if nbreElts>0 then
  387.     repeat while count(randomList)<nbreElts
  388.       r = random(nbreMaxi)
  389.       if getPos(randomList,r)=0 then
  390.         append randomList, r
  391.       end if
  392.     end repeat
  393.   end if
  394.   return randomList
  395. end
  396.  
  397. -- positions dans liste
  398. on positionsListe liste1
  399.   -- α partir de la liste liste1 construit liste2 telle que les ΘlΘments de liste2
  400.   -- sont les positions occupΘes par les nombres de 1 α n dans liste1
  401.   n = count(liste1)
  402.   liste2=[]
  403.   liste2[n] = 0
  404.   repeat with i=1 to n
  405.     p = getPos(liste1,i)
  406.     liste2[i]=p
  407.   end repeat
  408.   return liste2
  409. end
  410.  
  411. -- somme des termes d'une liste
  412. on sommeListe L
  413.   somme = 0
  414.   repeat with i=1 to count(L)
  415.     somme = somme + L[i]
  416.   end repeat
  417.   return somme
  418. end
  419.  
  420. -- envoi direct d'un mouseUp α une image objet
  421. on click piste
  422.   -- passe le message mouseUp α l'image objet piste
  423.   mouseUp(script (the scriptNum of sprite piste))
  424. end
  425.  
  426. -- teste la visibilitΘ d'un groupe de pistes
  427. on test piste1,piste2
  428.   testM=0
  429.   repeat with i=piste1 to piste2
  430.     testM = testM + sprite(i).visible
  431.   end repeat
  432.   return testM
  433. end
  434.  
  435. -- calcul de la distance entre deux points
  436. on distance x1,y1,x2,y2
  437.   -- calcule la distance entre un point de coordonnΘes (x1,y1)
  438.   -- et un point de coordonnΘes (x2,y2)
  439.   d = sqrt(power(abs(x1-x2),2)+power(abs(y1-y2),2))
  440.   return d
  441. end
  442.  
  443. -- calcul d'angle
  444. on calculAngle centre
  445.   -- centre : numΘro de la piste du point marquant le centre de la rotation
  446.   x1 = the mouseH
  447.   y1 = the mouseV
  448.   x0 = the locH of sprite centre
  449.   y0 = the locV of sprite centre
  450.   if x1=x0 then
  451.     if y1<y0 then
  452.       alpha0 = 0
  453.     else
  454.       alpha0 = 180
  455.     end if
  456.   else
  457.     tgalpha = 1.0*(Y1-Y0)/(X1-X0)
  458.     alpha = atan(tgalpha)
  459.     alpha0 = alpha*180/pi()
  460.     -- calcul de la valeur rΘelle de l'angle
  461.     if x1>x0 then
  462.       alpha0=90+alpha0
  463.     end if
  464.     if x1<x0 then
  465.       alpha0=270+alpha0
  466.     end if
  467.   end if
  468.   return alpha0
  469. end
  470.  
  471. -- conversion de degrΘs en radians
  472. on convDegRad deg
  473.   rad = (deg*(PI))/180.0
  474.   return rad
  475. end
  476.  
  477. -- Importation d'un fichier dans un acteur (nΘcessite fileXtra)
  478. on importer numActeur, type
  479.   -- numActeur est le numΘro de l'acteur dans lequel
  480.   -- doit avoir lieu l'importation
  481.   
  482.   -- teste le numΘro d'acteur pour l'importation
  483.   if value(numActeur)=0 then exit
  484.   -- controle de la prΘsence d'un type de fichier
  485.   if the paramCount=1 then
  486.     set type=""
  487.   else
  488.     set type=string(type)
  489.   end if
  490.   -- affichage d'une boεte de dialogue ouvrir
  491.   put fileopenDialog("",type) into nom
  492.   if nom<> "" then
  493.     importFileInto member numActeur, nom
  494.   end if
  495. end importer
  496.  
  497. -- Enregistrement d'un fichier texte sur le disque
  498. on enregistre acteur,texte1,texte2,mode
  499.   -- nΘcessite fileIO et fileXtra
  500.   -- acteur : numΘro de l'acteur texte α enregistrer
  501.   -- texte1 : nom de fichier par dΘfaut
  502.   -- texte2 : message de la boεte de dialogue
  503.   -- mode : 0 affiche une boite de dialogue
  504.   --        1 enregistre l'acteur au mΩme niveau que le film
  505.   --        2 enregistre l'acteur dans le dossier systΦme
  506.   if the paramCount=3 then
  507.     set mode =0
  508.   end if
  509.   case mode of
  510.     0:-- affichage d'une boεte de dialogue enregistrer sous
  511.       put FileSaveAsDialog(the pathName, texte1, texte2) into cible
  512.     1:-- enregistrement au niveau du film
  513.       set cible = the pathName & texte1
  514.     2:-- enregistrement dans le dossier systΦme
  515.       if the machineType = 256 then
  516.         set cible = getOsDirectory() & "\" & texte1
  517.       else
  518.         set cible = getOsDirectory() & texte1
  519.       end if
  520.   end case
  521.   if cible<>"" then
  522.     set enreg = new(xtra "fileIO")
  523.     createFile(enreg,cible)
  524.     openFile(enreg,cible,2)
  525.     set chaine = field acteur
  526.     writeString(enreg, chaine)
  527.     closeFile(enreg)
  528.   end if
  529. end
  530.  
  531. -- donne le volume de dΘmarrage
  532. on disqueBoot
  533.   if the machineType=256 then
  534.     volume = baSysFolder("windows")
  535.     set disque = volume.char[1..3]
  536.   else
  537.     volume = baSysFolder("prefs")
  538.     set disque = volume.char[1..(offset(":", volume)-1)]
  539.   end if
  540.   return disque
  541. end
  542.  
  543. -- donne l'espace disponible sur le volume de dΘmarrage
  544. on espaceDisque disque
  545.   return baDiskInfo(disque, "free")
  546. end
  547.  
  548. -- copie des textes sur le disque dur
  549. on textes
  550.   global chemin,cheminTextes
  551.   set lTextes=0
  552.   -- repΘrage du chemin d'accΦs au bureau (nΘcessite buddy API)
  553.   set disque=baSysFolder("desktop")
  554.   -- crΘation d'un dossier sur le bureau (nΘcessite filextra)
  555.   if the machineType<>256 then
  556.     -- sur Mac
  557.     set nom = disque & "textesMobiclic:"
  558.     createdirectory nom
  559.     set lTextes=1
  560.   else
  561.     if the platform="Windows,32" then
  562.       -- sous Windows 95 et 98
  563.       set nom = disque & "textesMobiclic\"
  564.       createdirectory nom
  565.       set lTextes=2
  566.     end if
  567.   end if
  568.   -- copie des textes sur le disque dur
  569.   XcopyDirectory cheminTextes, nom
  570.   -- message d'alerte
  571.   alert line lTextes of field "alertes"
  572. end
  573.  
  574.